﻿if (typeof(Admin) == 'undefined')
    Admin = {};
if (typeof(Admin.Account) == 'undefined')
    Admin.Account = {};

Admin.Account.List = {
    _options: {
        id: 'gridUserList',
        url: "Service/ListUser.ashx"
    },
    GetDataJson: function (url) {
        return new TIO().ajax(url);
    },
    ManipulateData: function (options) {
        var obj = $("#" + options.id + " > tbody");
        var data = new TIO().ajax(options.url);
        var result = "";
        for (i = 0; i < data.length; i++) {
            var item = data[i];
            result += $.Format(_format, item.UserId, item.UserName, item.Password, item.GroupUserId, item.IsActive);
        }
        obj.html(result);
    },
    Init: function () {
        this.ManipulateData(this._options);
    }
}

$(function () {
    Admin.Account.List.Init();
});

_format = "<tr>" + 
"<td class='a-center'>{0}</td>" +
"<td><a href='#'>{1}</a></td>" +
"<td{2}</td>" +
"<td>{3}</td>" +
"<td>{4}</td>" +
"<td>" +
    "<a href='#'>" +
        "<img src='../../img/icons/user.png' title='Show profile' width='16' height='16' /></a>" +
        "<a href='#'><img src='../../img/icons/user_edit.png' title='Edit user' width='16' height='16' /></a><a" +
                "href='#'><img src='../../img/icons/user_delete.png' title='Delete user' width='16' height='16' /></a>" +
"</td>" +
"</tr>";